﻿using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using EmbeddedSharp.Core;

namespace Zove.Desktop {
    public class SerializationHelper {

        public static List<BreakPoint> Deserialize(string fileName) {
            if (!File.Exists(fileName)) {
                return new List<BreakPoint>();
            }

            XmlSerializer deserializer = new XmlSerializer(typeof(List<BreakPoint>));
            TextReader textReader = new StreamReader(fileName);
            List<BreakPoint> bps = (List<BreakPoint>)deserializer.Deserialize(textReader);
            textReader.Close();

            return bps;
        }

        public static void Serialize(List<BreakPoint> list, string fileName) {
            XmlSerializer serializer = new XmlSerializer(typeof(List<BreakPoint>));
            TextWriter textWriter = new StreamWriter(fileName);
            serializer.Serialize(textWriter, list);
            textWriter.Close();
        }
    }
}
